<?php

// load Tonic library
require_once 'tonic.php';

// load examples
require_once 'examples/examples.php';

require_once 'src/model/model.php';
require_once 'src/rest/rest.php';

// handle request
$request = new Request(array(
    'baseUri' => '/mancala'
));

try {    
    $resource = $request->loadResource();
    $response = $resource->exec($request);

} catch (ResponseException $e) {
    switch ($e->getCode()) {
    case Response::UNAUTHORIZED:
        $response = $e->response($request);
        $response->addHeader('WWW-Authenticate', 'Basic realm="Tonic"');
        break;
    default:
        $response = $e->response($request);
    }
}
$response->output();
